
function profileInit(){
    //call yourself, your friends and app data to get the data
     var req = opensocial.newDataRequest();
     var opt_params = {};
     opt_params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [
                                        opensocial.Person.Field.NAME,
                                        opensocial.Person.Field.GENDER,
                                        opensocial.Person.Field.PROFILE_URL,
                                        opensocial.Person.Field.THUMBNAIL_URL];
										
	 opt_params[opensocial.DataRequest.PeopleRequestFields.FILTER] = opensocial.DataRequest.FilterType.HAS_APP; 
	 opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] = 240; 
     req.add(req.newFetchPersonRequest("OWNER", opt_params), "owner");
     req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.OWNER_FRIENDS, opt_params), 'ownerFriends');
    req.send(responseOnLoad);
}

function responseOnLoad(data){
    if(data.hadError()){
        alert("There was a problem communicating with the server, please try again later");
    }else{
                
            //show your name next to the greeting
            var owner = data.get("owner").getData();
            var ownerFriends = data.get('ownerFriends').getData();
            var name = owner.getDisplayName();
            document.getElementById('owner_name').innerHTML = name;
            
            
    }
}

function postActivity(){
      var buysell = document.getElementById('DropDownList1').value;
      
      var title = "create new event";
      
      var params = {};
      params[opensocial.Activity.Field.TITLE] = title;
      var activity = opensocial.newActivity(params);
      opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH, function() {});
      
      //send message to all your friends saying stuff
      
      //var message = opensocial.newMessage(myListingContainer[myListingContainer.length -1].descrption);
      //message.setField('TITLE', title);
}


function getWebService(){
     var soapBody = "<soap:Body><getCheers xmlns='http://gump.molecular.com/GadgetService'><userId>CD</userId></getCheers></soap:Body>";
     var postData =  marshallWithSoapHeaders(soapBody);
     var params = [];
    
     
    params[gadgets.io.RequestParameters.CONTENT_TYPE]=gadgets.io.ContentType.DOM;
    params[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;
    params[gadgets.io.RequestParameters.HEADERS]={"SOAPAction":"http://gump.molecular.com/GadgetService/getCheers"}; 
    params[gadgets.io.RequestParameters.POST_DATA] = postData; 
    var url = "http://gump.molecular.com/mcGadgetService/Service.asmx?op=getCheers"; 
    gadgets.io.makeRequest(url, response, params); 
    
    

}

function response(obj){

    console.log(obj);
    
    alert("response recieved");
}

function marshallWithSoapHeaders(soapBody){
 var header = "<?xml version='1.0' encoding='utf-8'?> <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>";   
 var postData = header + soapBody + "</soap:Envelope>";
 return postData;
}